<!DOCTYPE html>
<html>
<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="utf-8">
  
  <title>scons自动构建工具(二) | 小魏的博客</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  
    <meta name="keywords" content="Vker,Vker's Blog">
  
  <meta name="description" content="上一篇好像写的有点长了,上传不上去,所以又写了第二篇续写第一篇. 环境变量影响 scons 构建it uses the dictionary stored in the $ENV construction variable as the external environment for executing commands.解释: 它使用成字典的方式存储在 ENV 的构造变量中 作为外部可执行命令">
<meta name="keywords" content="python,c++,scons">
<meta property="og:type" content="article">
<meta property="og:title" content="scons自动构建工具(二)">
<meta property="og:url" content="https://leng521.top/posts/66615451/index.html">
<meta property="og:site_name" content="小魏的博客">
<meta property="og:description" content="上一篇好像写的有点长了,上传不上去,所以又写了第二篇续写第一篇. 环境变量影响 scons 构建it uses the dictionary stored in the $ENV construction variable as the external environment for executing commands.解释: 它使用成字典的方式存储在 ENV 的构造变量中 作为外部可执行命令">
<meta property="og:locale" content="default">
<meta property="og:updated_time" content="2019-08-14T03:22:53.957Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="scons自动构建工具(二)">
<meta name="twitter:description" content="上一篇好像写的有点长了,上传不上去,所以又写了第二篇续写第一篇. 环境变量影响 scons 构建it uses the dictionary stored in the $ENV construction variable as the external environment for executing commands.解释: 它使用成字典的方式存储在 ENV 的构造变量中 作为外部可执行命令">
  
  
    <link rel="icon" href="/head.jpg">
  
  <link href="//cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
  <link rel="stylesheet" href="/css/style.css">
  <script src="/js/pace.min.js"></script>
  

  
	<script>
	var _hmt = _hmt || [];
	(function() {
	  var hm = document.createElement("script");
	  hm.src = "//hm.baidu.com/hm.js?2eaff0c5326867354b0d3469d507d209";
	  var s = document.getElementsByTagName("script")[0]; 
	  s.parentNode.insertBefore(hm, s);
	})();
	</script>

  

</head>
</html>
<body>
  <div id="container">
      <header id="header">
    <div id="banner"></div>
    <div id="header-outer">
        <div id="header-menu" class="header-menu-pos animated">
            <div class="header-menu-container">
                <a href="/" class="left">
                    <span class="site-title">Vker&#39;s Blog</span>
                </a>
                <nav id="header-menu-nav" class="right">
                    
                    <a  href="/">
                        <i class="fa fa-home"></i>
                        <span>Home</span>
                    </a>
                    
                    <a  href="/archives">
                        <i class="fa fa-archive"></i>
                        <span>Archives</span>
                    </a>
                    
                    <a  href="/about">
                        <i class="fa fa-user"></i>
                        <span>About</span>
                    </a>
                    
                </nav>
                <a class="mobile-header-menu-button">
                    <i class="fa fa-bars"></i>
                </a>
            </div>
        </div>
        <div id="header-row">
            <div id="logo">
                <a href="/">
                    <img src="/head.jpg" alt="logo">
                </a>
            </div>
            <div class="header-info">
                <div id="header-title">
                    
                    <h2>
                        Vker&#39;s Blog
                    </h2>
                    
                </div>
                <div id="header-description">
                    
                    <h3>
                        一个专注 游戏研发 的技术博客
                    </h3>
                    
                </div>
            </div>
            <nav class="header-nav">
                <div class="social">
                    
                        <a title="Vker" target="_blank" href="//leng521.top">
                            <i class="fa fa-home fa-2x"></i></a>
                    
                        <a title="Github" target="_blank" href="//github.com">
                            <i class="fa fa-github fa-2x"></i></a>
                    
                        <a title="Weibo" target="_blank" href="//weibo.com">
                            <i class="fa fa-weibo fa-2x"></i></a>
                    
                        <a title="Twitter" target="_blank" href="//twitter.com">
                            <i class="fa fa-twitter fa-2x"></i></a>
                    
                </div>
            </nav>
        </div>
    </div>
</header>
      <div class="outer">
        <section id="main" class="body-wrap"><article id="post-scons自动构建工具-二" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-inner">
    
      <header class="article-header">
        
  
    <h1 class="post-title" itemprop="name">
      scons自动构建工具(二)
    </h1>
    <div class="post-title-bar">
      <ul>
          
              <li>
                  <i class="fa fa-book"></i>
                  
                      <a href="/categories/自动构建工具/">自动构建工具</a>
                  
              </li>
          
        <li>
          <i class="fa fa-calendar"></i>  2018-12-25
        </li>
        <li>
          <i class="fa fa-eye"></i>
          <span id="busuanzi_value_page_pv"></span>
        </li>
      </ul>
    </div>
  

          
      </header>
    
    <div class="article-entry post-content" itemprop="articleBody">
      
            
            <p>上一篇好像写的有点长了,上传不上去,所以又写了第二篇续写第一篇.</p>
<h3 id="环境变量影响-scons-构建"><a href="#环境变量影响-scons-构建" class="headerlink" title="环境变量影响 scons 构建"></a>环境变量影响 scons 构建</h3><p>it uses the dictionary stored in the $ENV construction variable as the external environment for executing commands.<br>解释: 它使用成字典的方式存储在 ENV 的构造变量中 作为外部可执行命令的环境<br><a id="more"></a><br><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line">添加 Path 环境变量到 ENV中执行</span><br><span class="line">path = [<span class="string">'/usr/local/bin'</span>, <span class="string">'/bin'</span>, <span class="string">'/usr/bin'</span>]</span><br><span class="line">env = Environment(ENV = &#123;<span class="string">'PATH'</span> : path&#125;)</span><br><span class="line"></span><br><span class="line">env[<span class="string">'ENV'</span>][<span class="string">'PATH'</span>] = [<span class="string">'/usr/local/bin'</span>, <span class="string">'/bin'</span>, <span class="string">'/usr/bin'</span>]</span><br><span class="line">env[<span class="string">'ENV'</span>][<span class="string">'PATH'</span>] = <span class="string">'/usr/local/bin:/bin:/usr/bin'</span></span><br><span class="line"></span><br><span class="line">因为是 scons 的配置文件是以 python 的环境执行的 所以 你可以使用 os.environ[<span class="string">'PATH'</span>] 获取环境变量, 例子如下:</span><br><span class="line">这样做,可以让自己的代码可移植,跨平台</span><br><span class="line"><span class="keyword">import</span> os</span><br><span class="line">env = Environment(ENV = &#123;<span class="string">'PATH'</span> : os.environ[<span class="string">'PATH'</span>]&#125;)</span><br><span class="line"></span><br><span class="line">或者你可以将整个 环境变量 全部赋值给 ENV</span><br><span class="line"><span class="keyword">import</span> os</span><br><span class="line">env = Environment(ENV = os.environ)</span><br><span class="line"></span><br><span class="line">你可以在已有的环境变量中 拼接 scons 提供如下的 方法:</span><br><span class="line">PrependENVPath()</span><br><span class="line">AppendENVPath()</span><br><span class="line">env =环境(ENV = os.environ)</span><br><span class="line">env.PrependENVPath(<span class="string">'PATH'</span>，<span class="string">'/ usr / local / bin'</span>)</span><br><span class="line">env.AppendENVPath(<span class="string">'LIB'</span>，<span class="string">'/ usr / local / lib'</span>)</span><br></pre></td></tr></table></figure></p>
<h3 id="使用外部工具"><a href="#使用外部工具" class="headerlink" title="使用外部工具"></a>使用外部工具</h3><p>使用外部工具的时候 scons 默认的搜索路径:<br>scons 内置工具目录<br>Sconstruct 同级目录下/site_scons/site_tools/</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># Builtin tool or tool located within site_tools</span></span><br><span class="line">env = Environment(tools = [<span class="string">'SomeTool'</span>])</span><br><span class="line">env.SomeTool(targets, sources)</span><br><span class="line"></span><br><span class="line"><span class="comment"># The search locations would include by default</span></span><br><span class="line">SCons/Tool/SomeTool.py</span><br><span class="line">SCons/Tool/SomeTool/__init__.py</span><br><span class="line">./site_scons/site_tools/SomeTool.py</span><br><span class="line">./site_scons/site_tools/SomeTool/__init__.py</span><br><span class="line"></span><br><span class="line">也可以给 添加 除了 scons 默认搜索路径</span><br><span class="line"><span class="comment"># Tool located within the toolpath directory option</span></span><br><span class="line">env = Environment(tools = [<span class="string">'SomeTool'</span>], toolpath = [<span class="string">'/opt/SomeToolPath'</span>, <span class="string">'/opt/SomeToolPath2'</span>])</span><br><span class="line">env.SomeTool(targets, sources)</span><br><span class="line"></span><br><span class="line"><span class="comment"># The search locations in this example would include:</span></span><br><span class="line">/opt/SomeToolPath/SomeTool.py</span><br><span class="line">/opt/SomeToolPath/SomeTool/__init__.py</span><br><span class="line">/opt/SomeToolPath2/SomeTool.py</span><br><span class="line">/opt/SomeToolPath2/SomeTool/__init__.py</span><br><span class="line">SCons/Tool/SomeTool.py</span><br><span class="line">SCons/Tool/SomeTool/__init__.py</span><br><span class="line">./site_scons/site_tools/SomeTool.py</span><br><span class="line">./site_scons/site_tools/SomeTool/__init__.py</span><br><span class="line"></span><br><span class="line">嵌套工具</span><br><span class="line"><span class="comment"># namespaced target</span></span><br><span class="line">env = Environment(tools = [<span class="string">'SubDir1.SubDir2.SomeTool'</span>], toolpath = [<span class="string">'/opt/SomeToolPath'</span>])</span><br><span class="line">env.SomeTool(targets, sources)</span><br><span class="line"></span><br><span class="line"><span class="comment"># With this example the search locations would include</span></span><br><span class="line">/opt/SomeToolPath/SubDir1/SubDir2/SomeTool.py</span><br><span class="line">/opt/SomeToolPath/SubDir1/SubDir2/SomeTool/__init__.py</span><br><span class="line">SCons/Tool/SubDir1/SubDir2/SomeTool.py</span><br><span class="line">SCons/Tool/SubDir1/SubDir2/SomeTool/__init__.py</span><br><span class="line">./site_scons/site_tools/SubDir1/SubDir2/SomeTool.py</span><br><span class="line">./site_scons/site_tools/SubDir1/SubDir2/SomeTool/__init__.py</span><br><span class="line"></span><br><span class="line">使用 sys.path 作为扩展的工具路径</span><br><span class="line"><span class="comment"># namespaced target using sys.path within toolpath</span></span><br><span class="line"><span class="keyword">import</span> sys</span><br><span class="line">searchpaths = []</span><br><span class="line"><span class="keyword">for</span> item <span class="keyword">in</span> sys.path:</span><br><span class="line">    <span class="keyword">if</span> os.path.isdir(item): searchpaths.append(item)</span><br><span class="line"></span><br><span class="line">env = Environment(tools = [<span class="string">'someinstalledpackage.SomeTool'</span>], toolpath = searchpaths)</span><br><span class="line">env.SomeTool(targets, sources)</span><br><span class="line"></span><br><span class="line">你可以使用这个包 来避免使用 pip 安装包 拼接前面复杂的路径</span><br><span class="line"><span class="comment"># namespaced target using sys.path</span></span><br><span class="line"><span class="keyword">import</span> sys</span><br><span class="line">env = Environment(tools = [<span class="string">'SomeTool'</span>], toolpath = [PyPackageDir(<span class="string">'tools_example.subdir1.subdir2'</span>)])</span><br><span class="line">env.SomeTool(targets, sources)</span><br></pre></td></tr></table></figure>
<hr>
<p>这次你了解 构造变量的这几个方法<br>MergeFlags, ParseFlags, and ParseConfig methods of a construction environment<br>MergeFlags, ParseFlags ParseConfig</p>
<p>###<br><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br></pre></td><td class="code"><pre><span class="line">MergeFlags</span><br><span class="line">尝试合并某个构造变量 例子如下:</span><br><span class="line"></span><br><span class="line">env = Environment()</span><br><span class="line">env.Append(CCFLAGS = <span class="string">'-option -O3 -O1'</span>)</span><br><span class="line">flags = &#123; <span class="string">'CCFLAGS'</span> : <span class="string">'-whatever -O3'</span> &#125;</span><br><span class="line">env.MergeFlags(flags)</span><br><span class="line"><span class="keyword">print</span> env[<span class="string">'CCFLAGS'</span>]</span><br><span class="line"></span><br><span class="line">&gt;&gt;&gt;&gt;</span><br><span class="line">scons -Q</span><br><span class="line">[<span class="string">'-option'</span>, <span class="string">'-O1'</span>, <span class="string">'-whatever'</span>, <span class="string">'-O3'</span>]</span><br><span class="line">scons: <span class="string">'.'</span> <span class="keyword">is</span> up to date.</span><br><span class="line"></span><br><span class="line">env = Environment()</span><br><span class="line">env.Append(CPPPATH = [<span class="string">'/include'</span>, <span class="string">'/usr/local/include'</span>, <span class="string">'/usr/include'</span>])</span><br><span class="line">flags = &#123; <span class="string">'CPPPATH'</span> : [<span class="string">'/usr/opt/include'</span>, <span class="string">'/usr/local/include'</span>] &#125;</span><br><span class="line">env.MergeFlags(flags)</span><br><span class="line"><span class="keyword">print</span> env[<span class="string">'CPPPATH'</span>]</span><br><span class="line"></span><br><span class="line">&gt;&gt;&gt;&gt;</span><br><span class="line">scons -Q</span><br><span class="line">[<span class="string">'/include'</span>, <span class="string">'/usr/local/include'</span>, <span class="string">'/usr/include'</span>, <span class="string">'/usr/opt/include'</span>]</span><br><span class="line">scons: <span class="string">'.'</span> <span class="keyword">is</span> up to date.</span><br><span class="line"></span><br><span class="line">如果我们这个方法传递的不是列表 scons 会自动调用 ParseFlags 将其解析成列表</span><br><span class="line">env = Environment()</span><br><span class="line">env.Append(CCFLAGS = <span class="string">'-option -O3 -O1'</span>)</span><br><span class="line">env.Append(CPPPATH = [<span class="string">'/include'</span>, <span class="string">'/usr/local/include'</span>, <span class="string">'/usr/include'</span>])</span><br><span class="line">env.MergeFlags(<span class="string">'-whatever -I/usr/opt/include -O3 -I/usr/local/include'</span>)</span><br><span class="line"><span class="keyword">print</span> env[<span class="string">'CCFLAGS'</span>]</span><br><span class="line"><span class="keyword">print</span> env[<span class="string">'CPPPATH'</span>]</span><br><span class="line"></span><br><span class="line">&gt;&gt;&gt;&gt;</span><br><span class="line">scons -Q</span><br><span class="line">[<span class="string">'-option'</span>, <span class="string">'-O1'</span>, <span class="string">'-whatever'</span>, <span class="string">'-O3'</span>]</span><br><span class="line">[<span class="string">'/include'</span>, <span class="string">'/usr/local/include'</span>, <span class="string">'/usr/include'</span>, <span class="string">'/usr/opt/include'</span>]</span><br><span class="line">scons: `.<span class="string">' is up to date.</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">ParseFlags </span></span><br><span class="line"><span class="string">[ParseFlags](https://scons.org/doc/production/HTML/scons-user/ch08s02.html)</span></span><br><span class="line"><span class="string">讲一个有规律的字符串 解析成一个字典列表</span></span><br><span class="line"><span class="string">-I 指要包含的 源码路径</span></span><br><span class="line"><span class="string">-L 库文件的路径</span></span><br><span class="line"><span class="string">env = Environment()</span></span><br><span class="line"><span class="string">d = env.ParseFlags("-I/opt/include -L/opt/lib -lfoo")</span></span><br><span class="line"><span class="string">for k,v in sorted(d.items()):</span></span><br><span class="line"><span class="string">    if v:</span></span><br><span class="line"><span class="string">        print k, v</span></span><br><span class="line"><span class="string">env.MergeFlags(d)</span></span><br><span class="line"><span class="string">env.Program('</span>f1.c<span class="string">')</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">支持递归输入 主要是看例子 和输出结果去理解这些东西, 这里官方也没有解释的太清楚 后面还得多去实践的真知</span></span><br><span class="line"><span class="string">env = Environment()</span></span><br><span class="line"><span class="string">d = env.ParseFlags(["-I/opt/include", ["-L/opt/lib", "-lfoo"]])</span></span><br><span class="line"><span class="string">for k,v in sorted(d.items()):</span></span><br><span class="line"><span class="string">    if v:</span></span><br><span class="line"><span class="string">        print k, v</span></span><br><span class="line"><span class="string">env.MergeFlags(d)</span></span><br><span class="line"><span class="string">env.Program('</span>f1.c<span class="string">')</span></span><br><span class="line"><span class="string">&gt;&gt;&gt;&gt;</span></span><br><span class="line"><span class="string">% scons -Q</span></span><br><span class="line"><span class="string">CPPPATH ['</span>/opt/include<span class="string">']</span></span><br><span class="line"><span class="string">LIBPATH ['</span>/opt/li<span class="string">b']</span></span><br><span class="line"><span class="string">LIBS ['</span>foo<span class="string">']</span></span><br><span class="line"><span class="string">cc -o f1.o -c -I/opt/include f1.c</span></span><br><span class="line"><span class="string">cc -o f1 f1.o -L/opt/lib -lfoo</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">ParseConfig</span></span><br><span class="line"><span class="string">这个东西没有看明白 这里先记录一下链接</span></span><br><span class="line"><span class="string">Finding Installed Library Information: the ParseConfig Function</span></span><br><span class="line"><span class="string">[ParseConfig](https://scons.org/doc/production/HTML/scons-user/ch08s03.html)</span></span><br></pre></td></tr></table></figure></p>
<h3 id="在构建程序的时候-帮助信息"><a href="#在构建程序的时候-帮助信息" class="headerlink" title="在构建程序的时候 帮助信息"></a>在构建程序的时候 帮助信息</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><span class="line">Help(<span class="string">"""</span></span><br><span class="line"><span class="string">Type: 'scons program' to build the production program,</span></span><br><span class="line"><span class="string">      'scons debug' to build the debug version.</span></span><br><span class="line"><span class="string">"""</span>, append=<span class="literal">True</span>)</span><br><span class="line"></span><br><span class="line">加上 append = <span class="literal">True</span> 在下面出现 `Use scons -H <span class="keyword">for</span> help about command-line options.` 这样的字段</span><br><span class="line"></span><br><span class="line">&gt;&gt;&gt;&gt;</span><br><span class="line"></span><br><span class="line">scons -h</span><br><span class="line">scons: Reading SConscript files ...</span><br><span class="line">scons: done reading SConscript files.</span><br><span class="line"></span><br><span class="line">Type: <span class="string">'scons program'</span> to build the production program,</span><br><span class="line">      <span class="string">'scons debug'</span> to build the debug version.</span><br><span class="line"></span><br><span class="line">Use scons -H <span class="keyword">for</span> help about command-line options.</span><br><span class="line"></span><br><span class="line">你可以缩短的 命令输出 如下这种操作</span><br><span class="line">env = Environment(CCCOMSTR = <span class="string">"Compiling $TARGET"</span>,</span><br><span class="line">                  LINKCOMSTR = <span class="string">"Linking $TARGET"</span>)</span><br><span class="line">env.Program(<span class="string">'foo.c'</span>)</span><br><span class="line"></span><br><span class="line">&gt;&gt;&gt;&gt;</span><br><span class="line">% scons -Q</span><br><span class="line">Compiling foo.o</span><br><span class="line">Linking foo</span><br><span class="line"></span><br><span class="line">比如下面的例子 如果用户输入的 详细字段不为 <span class="literal">True</span> 则自定义 编译命令 其实是简短编译命令</span><br><span class="line">env = Environment()</span><br><span class="line"><span class="keyword">if</span> ARGUMENTS.get(<span class="string">'VERBOSE'</span>) != <span class="string">"1':</span></span><br><span class="line"><span class="string">    env['CCCOMSTR'] = "</span>Compiling $TARGET<span class="string">"</span></span><br><span class="line"><span class="string">    env['LINKCOMSTR'] = "</span>Linking $TARGET<span class="string">"</span></span><br><span class="line"><span class="string">env.Program('foo.c')</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">Progress 控制流程输出</span></span><br><span class="line"><span class="string">[Progress](https://scons.org/doc/production/HTML/scons-user/ch09s03.html)</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">GetBuildFailures</span></span><br><span class="line"><span class="string">[打印详细的错误信息](https://scons.org/doc/production/HTML/scons-user/ch09s04.html)</span></span><br></pre></td></tr></table></figure>
<h3 id="从命令行控制构建流程"><a href="#从命令行控制构建流程" class="headerlink" title="从命令行控制构建流程"></a>从命令行控制构建流程</h3><p><a href="https://scons.org/doc/production/HTML/scons-user/ch10.html">传送门</a><br><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br></pre></td><td class="code"><pre><span class="line">&gt;&gt;&gt;&gt; 如果你想使用者调用一些除了scons提供的指令,你可以这样做</span><br><span class="line"></span><br><span class="line">ARGUMENTS 这个东西将会帮到你.</span><br><span class="line">但是有个缺陷是不能存储两个值,只能 key-value 的形式.</span><br><span class="line">ARGUMENTS.get() 获取 debug 这个指令 没有用后面的默认值</span><br><span class="line"></span><br><span class="line">env = Environment()</span><br><span class="line">debug = ARGUMENTS.get(<span class="string">'debug'</span>, <span class="number">0</span>)</span><br><span class="line"><span class="keyword">if</span> int(debug):</span><br><span class="line">    env.Append(CCFLAGS = <span class="string">'-g'</span>)</span><br><span class="line">env.Program(<span class="string">'prog.c'</span>)</span><br><span class="line"></span><br><span class="line">ej:</span><br><span class="line">scons -Q debug=<span class="number">0</span></span><br><span class="line"></span><br><span class="line">&gt;&gt;&gt;&gt; 如果你想 一对多 你可以使用这个东西</span><br><span class="line">ARGLIST</span><br><span class="line"></span><br><span class="line">cppdefines = []</span><br><span class="line"><span class="keyword">for</span> key, value <span class="keyword">in</span> ARGLIST:</span><br><span class="line">    <span class="keyword">if</span> key == <span class="string">'define'</span>:</span><br><span class="line">        cppdefines.append(value)</span><br><span class="line">env = Environment(CPPDEFINES = cppdefines)</span><br><span class="line">env.Object(<span class="string">'prog.c'</span>)</span><br><span class="line"></span><br><span class="line">ej: scons -Q define=FOO define=BAR</span><br><span class="line"></span><br><span class="line">&gt;&gt;&gt;&gt; 从文件中读取用户构建配置</span><br><span class="line">&gt;&gt;&gt;&gt; 会读取 custom.py 文件的配置表</span><br><span class="line">vars = Variables(<span class="string">'custom.py'</span>)</span><br><span class="line">vars.Add(<span class="string">'RELEASE'</span>, <span class="string">'Set to 1 to build for release'</span>, <span class="number">0</span>)</span><br><span class="line">env = Environment(variables = vars,</span><br><span class="line">                  CPPDEFINES=&#123;<span class="string">'RELEASE_BUILD'</span> : <span class="string">'$&#123;RELEASE&#125;'</span>&#125;)</span><br><span class="line">env.Program([<span class="string">'foo.c'</span>, <span class="string">'bar.c'</span>])</span><br><span class="line">Help(vars.GenerateHelpText(env))</span><br><span class="line"></span><br><span class="line">&gt;&gt;&gt;&gt; custom.py</span><br><span class="line">&gt;&gt;&gt;&gt; RELEASE=<span class="number">1</span></span><br><span class="line"></span><br><span class="line">&gt;&gt;&gt;&gt; 可以结合 两种做法 读取用户 在命令行输入或则是配置文件</span><br><span class="line">&gt;&gt;&gt;&gt; 其中 本地配置文件会首先 覆盖 命令行 的 配置</span><br><span class="line">vars = Variables(<span class="string">'custom.py'</span>,ARGUMENTS)</span><br><span class="line"></span><br><span class="line">&gt;&gt;&gt;&gt; 定义构造变量的函数</span><br><span class="line">&gt;&gt;&gt;&gt; Bool 可以指定的值有 true =&gt; t on all 1 true    False =&gt; f 0 no false</span><br><span class="line"></span><br><span class="line">vars = Variables(<span class="string">'custom.py'</span>)</span><br><span class="line">vars.Add(BoolVariable(<span class="string">'RELEASE'</span>, <span class="string">'Set to build for release'</span>, <span class="number">0</span>))</span><br><span class="line">env = Environment(variables = vars,</span><br><span class="line">                  CPPDEFINES=&#123;<span class="string">'RELEASE_BUILD'</span> : <span class="string">'$&#123;RELEASE&#125;'</span>&#125;)</span><br><span class="line">env.Program(<span class="string">'foo.c'</span>)</span><br><span class="line"></span><br><span class="line">ej:</span><br><span class="line">scons -Q RELEASE=yes foo.o</span><br><span class="line"></span><br><span class="line">&gt;&gt;&gt;&gt; Enum 有个 allowed_values 的字段 定义枚举变量值</span><br><span class="line">&gt;&gt;&gt;&gt; map 字段备用映射名 map=&#123;<span class="string">'navy'</span>:<span class="string">'blue'</span>&#125;,</span><br><span class="line">&gt;&gt;&gt;&gt; ignorecase=<span class="number">1</span> 忽略 指定指令的大小写  如 COLOR=NaVy</span><br><span class="line"></span><br><span class="line">vars = Variables(<span class="string">'custom.py'</span>)</span><br><span class="line">vars.Add(EnumVariable(<span class="string">'COLOR'</span>, <span class="string">'Set background color'</span>, <span class="string">'red'</span>,</span><br><span class="line">                    allowed_values=(<span class="string">'red'</span>, <span class="string">'green'</span>, <span class="string">'blue'</span>)))</span><br><span class="line">env = Environment(variables = vars,</span><br><span class="line">                  CPPDEFINES=&#123;<span class="string">'COLOR'</span> : <span class="string">'"$&#123;COLOR&#125;"'</span>&#125;)</span><br><span class="line">env.Program(<span class="string">'foo.c'</span>)</span><br><span class="line"></span><br><span class="line">ej: scons -Q COLOR=red</span><br><span class="line"></span><br><span class="line">&gt;&gt;&gt;&gt; ListVariable 允许一个字段指定多个值</span><br><span class="line">&gt;&gt;&gt;&gt; 允许使用 all 或则是 none</span><br><span class="line"></span><br><span class="line">vars = Variables(<span class="string">'custom.py'</span>)</span><br><span class="line">vars.Add(ListVariable(<span class="string">'COLORS'</span>, <span class="string">'List of colors'</span>, <span class="number">0</span>,</span><br><span class="line">                    [<span class="string">'red'</span>, <span class="string">'green'</span>, <span class="string">'blue'</span>]))</span><br><span class="line">env = Environment(variables = vars,</span><br><span class="line">                  CPPDEFINES=&#123;<span class="string">'COLORS'</span> : <span class="string">'"$&#123;COLORS&#125;"'</span>&#125;)</span><br><span class="line">env.Program(<span class="string">'foo.c'</span>)</span><br><span class="line"></span><br><span class="line">ej: scons -Q COLORS=red,blue foo.o =&gt; cc -o foo.o -c -DCOLORS="red blue" foo.c</span><br><span class="line">ej: scons -Q COLORS=all foo.o =&gt; cc -o foo.o -c -DCOLORS="red green blue" foo.c</span><br><span class="line">ej: scons -Q COLORS=none foo.o =&gt; cc -o foo.o -c -DCOLORS="" foo.c</span><br><span class="line"></span><br><span class="line">&gt;&gt;&gt;&gt; PathVariable 路径变量</span><br><span class="line">&gt;&gt;&gt;&gt; 提供输入的路径是文件 PathVariable.PathIsFile</span><br><span class="line">&gt;&gt;&gt;&gt; 是目录 PathVariable.PathIsDir</span><br><span class="line">&gt;&gt;&gt;&gt; 目录不存在,并创建 PathVariable.PathIsDirCreate</span><br><span class="line">&gt;&gt;&gt;&gt; 不关心上面的三点 PathVariable.PathAccept</span><br><span class="line"></span><br><span class="line">ej:</span><br><span class="line">vars = Variables(<span class="string">'custom.py'</span>)</span><br><span class="line">vars.Add(PathVariable(<span class="string">'CONFIG'</span>,</span><br><span class="line">                    <span class="string">'Path to configuration file'</span>,</span><br><span class="line">                    <span class="string">'/etc/my_config'</span>,</span><br><span class="line">                    PathVariable.PathIsFile))</span><br><span class="line">env = Environment(variables = vars,</span><br><span class="line">                  CPPDEFINES=&#123;<span class="string">'CONFIG_FILE'</span> : <span class="string">'"$CONFIG"'</span>&#125;)</span><br><span class="line">env.Program(<span class="string">'foo.c'</span>)</span><br><span class="line"></span><br><span class="line">&gt;&gt;&gt;&gt; PackageVariable</span><br><span class="line">&gt;&gt;&gt;&gt; 启用或禁止 路径名字 没有太懂</span><br><span class="line">vars = Variables(<span class="string">'custom.py'</span>)</span><br><span class="line">vars.Add(PackageVariable(<span class="string">'PACKAGE'</span>,</span><br><span class="line">                       <span class="string">'Location package'</span>,</span><br><span class="line">                       <span class="string">'/opt/location'</span>))</span><br><span class="line">env = Environment(variables = vars,</span><br><span class="line">                  CPPDEFINES=&#123;<span class="string">'PACKAGE'</span> : <span class="string">'"$PACKAGE"'</span>&#125;)</span><br><span class="line">env.Program(<span class="string">'foo.c'</span>)</span><br><span class="line"></span><br><span class="line">ej:</span><br><span class="line">% scons -Q foo.o</span><br><span class="line">cc -o foo.o -c -DPACKAGE=<span class="string">"/opt/location"</span> foo.c</span><br><span class="line">% scons -Q PACKAGE=/usr/local/location foo.o</span><br><span class="line">cc -o foo.o -c -DPACKAGE=<span class="string">"/usr/local/location"</span> foo.c</span><br><span class="line">% scons -Q PACKAGE=yes foo.o</span><br><span class="line">cc -o foo.o -c -DPACKAGE=<span class="string">"True"</span> foo.c</span><br><span class="line">% scons -Q PACKAGE=no foo.o</span><br><span class="line">cc -o foo.o -c -DPACKAGE=<span class="string">"False"</span> foo.c</span><br><span class="line"></span><br><span class="line">&gt;&gt;&gt;&gt; AddVariables 一次性添加多个变量功能</span><br><span class="line"></span><br><span class="line">vars = Variables()</span><br><span class="line">vars.AddVariables(</span><br><span class="line">    (<span class="string">'RELEASE'</span>, <span class="string">'Set to 1 to build for release'</span>, <span class="number">0</span>),</span><br><span class="line">    (<span class="string">'CONFIG'</span>, <span class="string">'Configuration file'</span>, <span class="string">'/etc/my_config'</span>),</span><br><span class="line">    BoolVariable(<span class="string">'warnings'</span>, <span class="string">'compilation with -Wall and similiar'</span>, <span class="number">1</span>),</span><br><span class="line">    EnumVariable(<span class="string">'debug'</span>, <span class="string">'debug output and symbols'</span>, <span class="string">'no'</span>,</span><br><span class="line">               allowed_values=(<span class="string">'yes'</span>, <span class="string">'no'</span>, <span class="string">'full'</span>),</span><br><span class="line">               map=&#123;&#125;, ignorecase=<span class="number">0</span>),  <span class="comment"># case sensitive</span></span><br><span class="line">    ListVariable(<span class="string">'shared'</span>,</span><br><span class="line">               <span class="string">'libraries to build as shared libraries'</span>,</span><br><span class="line">               <span class="string">'all'</span>,</span><br><span class="line">               names = list_of_libs),</span><br><span class="line">    PackageVariable(<span class="string">'x11'</span>,</span><br><span class="line">                  <span class="string">'use X11 installed here (yes = search some places)'</span>,</span><br><span class="line">                  <span class="string">'yes'</span>),</span><br><span class="line">    PathVariable(<span class="string">'qtdir'</span>, <span class="string">'where the root of Qt is installed'</span>, qtdir),</span><br><span class="line">)</span><br><span class="line"></span><br><span class="line">&gt;&gt;&gt;&gt; UnknownVariables 在用户使用了未定义的 指令时 你可以警告调用者 拼写错误 并退出程序</span><br><span class="line"></span><br><span class="line">vars = Variables(<span class="literal">None</span>)</span><br><span class="line">vars.Add(<span class="string">'RELEASE'</span>, <span class="string">'Set to 1 to build for release'</span>, <span class="number">0</span>)</span><br><span class="line">env = Environment(variables = vars,</span><br><span class="line">                  CPPDEFINES=&#123;<span class="string">'RELEASE_BUILD'</span> : <span class="string">'$&#123;RELEASE&#125;'</span>&#125;)</span><br><span class="line">unknown = vars.UnknownVariables()</span><br><span class="line"><span class="keyword">if</span> unknown:</span><br><span class="line">    print(<span class="string">"Unknown variables: %s"</span>%unknown.keys())</span><br><span class="line">    Exit(<span class="number">1</span>)</span><br><span class="line">env.Program(<span class="string">'foo.c'</span>)</span><br><span class="line"></span><br><span class="line">&gt;&gt;&gt;&gt; 你可以在用户使用某个命令的时候 提醒用户一些操作</span><br><span class="line"><span class="keyword">if</span> <span class="string">'bar'</span> <span class="keyword">in</span> COMMAND_LINE_TARGETS:</span><br><span class="line">    print(<span class="string">"Don't forget to copy `bar' to the archive!"</span>)</span><br><span class="line">Default(Program(<span class="string">'foo.c'</span>))</span><br><span class="line">Program(<span class="string">'bar.c'</span>)</span><br><span class="line"></span><br><span class="line">ej:</span><br><span class="line">% scons -Q bar</span><br><span class="line">Don<span class="string">'t forget to copy `bar'</span> to the archive!</span><br><span class="line"></span><br><span class="line">&gt;&gt;&gt;&gt; Default() 用户没有指定构建是 可以使用 这个函数 默认 构建一个程序</span><br><span class="line">env = Environment()</span><br><span class="line">hello = env.Program(<span class="string">'hello.c'</span>)</span><br><span class="line">env.Program(<span class="string">'goodbye.c'</span>)</span><br><span class="line">Default(hello)</span><br><span class="line"></span><br><span class="line">ej:</span><br><span class="line">    % scons -Q</span><br><span class="line">    cc -o hello.o -c hello.c</span><br><span class="line">    cc -o hello hello.o</span><br><span class="line">    % scons -Q</span><br><span class="line">    scons: `hello<span class="string">' is up to date.</span></span><br><span class="line"><span class="string">    % scons -Q goodbye</span></span><br><span class="line"><span class="string">    cc -o goodbye.o -c goodbye.c</span></span><br><span class="line"><span class="string">    cc -o goodbye goodbye.o</span></span><br><span class="line"><span class="string">Default 跟过用法 [传送门](https://scons.org/doc/production/HTML/scons-user/ch10s03.html)</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">&gt;&gt;&gt;&gt; DEFAULT_TARGETS 主要是迎合上面 Default 函数, 看一下例子应该很容易理解</span></span><br><span class="line"><span class="string">prog1 = Program('</span>prog1.c<span class="string">')</span></span><br><span class="line"><span class="string">Default(prog1)</span></span><br><span class="line"><span class="string">print("DEFAULT_TARGETS is %s"%map(str, DEFAULT_TARGETS))</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">ej:</span></span><br><span class="line"><span class="string">% scons</span></span><br><span class="line"><span class="string">scons: Reading SConscript files ...</span></span><br><span class="line"><span class="string">DEFAULT_TARGETS is ['</span>prog1<span class="string">']</span></span><br><span class="line"><span class="string">scons: done reading SConscript files.</span></span><br><span class="line"><span class="string">scons: Building targets ...</span></span><br><span class="line"><span class="string">cc -o prog1.o -c prog1.c</span></span><br><span class="line"><span class="string">cc -o prog1 prog1.o</span></span><br><span class="line"><span class="string">scons: done building targets.</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">&gt;&gt;&gt;&gt; BUILD_TARGETS</span></span><br><span class="line"><span class="string">prog1 = Program('</span>prog1.c<span class="string">')</span></span><br><span class="line"><span class="string">Program('</span>prog2.c<span class="string">')</span></span><br><span class="line"><span class="string">Default(prog1)</span></span><br><span class="line"><span class="string">print ("BUILD_TARGETS is %s"%map(str, BUILD_TARGETS))</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">ej:</span></span><br><span class="line"><span class="string">% scons -Q</span></span><br><span class="line"><span class="string">BUILD_TARGETS is ['</span>prog1<span class="string">']</span></span><br><span class="line"><span class="string">cc -o prog1.o -c prog1.c</span></span><br><span class="line"><span class="string">cc -o prog1 prog1.o</span></span><br><span class="line"><span class="string">% scons -Q prog2</span></span><br><span class="line"><span class="string">BUILD_TARGETS is ['</span>prog2<span class="string">']</span></span><br><span class="line"><span class="string">cc -o prog2.o -c prog2.c</span></span><br><span class="line"><span class="string">cc -o prog2 prog2.o</span></span><br><span class="line"><span class="string">% scons -Q -c .</span></span><br><span class="line"><span class="string">BUILD_TARGETS is ['</span>.<span class="string">']</span></span><br><span class="line"><span class="string">Removed prog1.o</span></span><br><span class="line"><span class="string">Removed prog1</span></span><br><span class="line"><span class="string">Removed prog2.o</span></span><br><span class="line"><span class="string">Removed prog2</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">&gt;&gt;&gt;&gt; 产生帮助文档(help)</span></span><br><span class="line"><span class="string">vars = Variables(None, ARGUMENTS)</span></span><br><span class="line"><span class="string">vars.Add('</span>RELEASE<span class="string">', '</span>Set to <span class="number">1</span> to build <span class="keyword">for</span> release<span class="string">', 0)</span></span><br><span class="line"><span class="string">env = Environment(variables = vars)</span></span><br><span class="line"><span class="string">Help(vars.GenerateHelpText(env))</span></span><br></pre></td></tr></table></figure></p>
<h3 id="InstallBuilder-安装构建的可执行程序"><a href="#InstallBuilder-安装构建的可执行程序" class="headerlink" title="InstallBuilder 安装构建的可执行程序"></a>InstallBuilder 安装构建的可执行程序</h3><p>安装暂时没有 显示功能上需求就不做详细叙述了<br><a href="https://scons.org/doc/production/HTML/scons-user/ch11.html">传送门</a></p>
<h3 id="与平台无关的文件操作"><a href="#与平台无关的文件操作" class="headerlink" title="与平台无关的文件操作"></a>与平台无关的文件操作</h3><p>scons 封装了 与平台无关的文件操作<br>如: 拷贝(copy),移动(move),移除(delete),创建(touch),创建目录(mkdir),执行(execute)<br><a href="https://scons.org/doc/production/HTML/scons-user/ch12.html">传送门</a>WWW</p>
<h3 id="控制构建目标的移除"><a href="#控制构建目标的移除" class="headerlink" title="控制构建目标的移除"></a>控制构建目标的移除</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line">&gt;&gt;&gt;&gt; 有的时候你想要在每次构建一个东西的时候,不清除上一次的构建,而是以增量的方式构建</span><br><span class="line">&gt;&gt;&gt;&gt; Precious</span><br><span class="line">env = Environment(RANLIBCOM=<span class="string">''</span>)</span><br><span class="line">lib = env.Library(<span class="string">'foo'</span>, [<span class="string">'f1.c'</span>, <span class="string">'f2.c'</span>, <span class="string">'f3.c'</span>])</span><br><span class="line">env.Precious(lib)</span><br><span class="line"></span><br><span class="line">&gt;&gt;&gt;&gt; 有的时候你可能使用 scons -c 但是这个命令会将所有的构建产物都移除掉,你可以使用这个命令,保证有些东西不被 -c 指令 给移除掉</span><br><span class="line">&gt;&gt;&gt;&gt; NoClean</span><br><span class="line">env = Environment(RANLIBCOM=<span class="string">''</span>)</span><br><span class="line">lib = env.Library(<span class="string">'foo'</span>, [<span class="string">'f1.c'</span>, <span class="string">'f2.c'</span>, <span class="string">'f3.c'</span>])</span><br><span class="line">env.NoClean(lib)</span><br><span class="line"></span><br><span class="line">&gt;&gt;&gt;&gt; Clean 有的时候你可能 清楚自己在产生过程中生成的 自定义文件 你可以这样做</span><br><span class="line">t = Command(<span class="string">'foo.out'</span>, <span class="string">'foo.in'</span>, <span class="string">'build -o $TARGET $SOURCE'</span>)</span><br><span class="line">Clean(t, <span class="string">'foo.log'</span>)</span><br><span class="line"></span><br><span class="line">ej:</span><br><span class="line">% scons -Q</span><br><span class="line">build -o foo.out foo.<span class="keyword">in</span></span><br><span class="line">% scons -Q -c</span><br><span class="line">Removed foo.out</span><br><span class="line">Removed foo.log</span><br></pre></td></tr></table></figure>
<h3 id="分级构建"><a href="#分级构建" class="headerlink" title="分级构建"></a>分级构建</h3><p>分级构建,就是你的源文件可能不是一个目录,需要多一个目录构建.<br><a href="https://scons.org/doc/production/HTML/scons-user/ch14.html">传送门</a><br><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br></pre></td><td class="code"><pre><span class="line">&gt;&gt;&gt;&gt; SConscript 根目录调用每个子目录的 构建脚本, 通常子目录的构建脚本叫 SConscript 这是官方的解释</span><br><span class="line">SConscript([<span class="string">'drivers/display/SConscript'</span>,</span><br><span class="line">            <span class="string">'drivers/mouse/SConscript'</span>,</span><br><span class="line">            <span class="string">'parser/SConscript'</span>,</span><br><span class="line">            <span class="string">'utilities/SConscript'</span>])</span><br><span class="line"></span><br><span class="line">&gt;&gt;&gt;&gt; 通常里面的路径都是相对于当前这个构建脚本 如果你先让子构建脚本 使用顶级目录你可以这样做 加上 <span class="string">'#'</span> 这个符号</span><br><span class="line">env = Environment()</span><br><span class="line">env.Program(<span class="string">'prog'</span>, [<span class="string">'main.c'</span>, <span class="string">'#lib/foo1.c'</span>, <span class="string">'foo2.c'</span>])</span><br><span class="line"></span><br><span class="line">&gt;&gt;&gt;&gt; 当然你也可以直接使用绝对路径 不需要加任何符号</span><br><span class="line">&gt;&gt;&gt;&gt; </span><br><span class="line">&gt;&gt;&gt;&gt; 你可以在多个构建脚本共享变量 你可以使用 Export Import 这两个方法</span><br><span class="line"></span><br><span class="line">ej:</span><br><span class="line">env = Environment()</span><br><span class="line">Export(env)</span><br><span class="line"></span><br><span class="line"><span class="keyword">or</span>:</span><br><span class="line">env = Environment()</span><br><span class="line">debug = <span class="number">10</span></span><br><span class="line">Export(env, debug)</span><br><span class="line"></span><br><span class="line"><span class="keyword">or</span>:</span><br><span class="line">Export(<span class="string">'env debug'</span>)</span><br><span class="line"></span><br><span class="line"><span class="keyword">or</span>:</span><br><span class="line">SConscript(<span class="string">'src/SConscript'</span>, <span class="string">'env'</span>)</span><br><span class="line"></span><br><span class="line"><span class="keyword">or</span>:</span><br><span class="line">SConscript(<span class="string">'src/SConscript'</span>, exports=<span class="string">'env'</span>)</span><br><span class="line"></span><br><span class="line">ej:</span><br><span class="line">Import(env)</span><br><span class="line"></span><br><span class="line">Import(env, debug)</span><br><span class="line"></span><br><span class="line">Import(<span class="string">'env debug'</span>)</span><br><span class="line"></span><br><span class="line">Import(<span class="string">'*'</span>)</span><br><span class="line"></span><br><span class="line">&gt;&gt;&gt;&gt; 有事你需要 从两个此目录返回结果 构建出一个对象</span><br><span class="line">env = Environment()</span><br><span class="line">Export(<span class="string">'env'</span>)</span><br><span class="line">objs = []</span><br><span class="line"><span class="keyword">for</span> subdir <span class="keyword">in</span> [<span class="string">'foo'</span>, <span class="string">'bar'</span>]:</span><br><span class="line">    o = SConscript(<span class="string">'%s/SConscript'</span> % subdir)</span><br><span class="line">    objs.append(o)</span><br><span class="line">env.Library(<span class="string">'prog'</span>, objs)</span><br><span class="line"></span><br><span class="line">other Sconstruct(其他构建脚本):</span><br><span class="line">    Import(<span class="string">'env'</span>)</span><br><span class="line">    obj = env.Object(<span class="string">'foo.c'</span>)</span><br><span class="line">    Return(<span class="string">'obj'</span>)</span><br><span class="line"></span><br><span class="line">&gt;&gt;&gt;&gt;</span><br></pre></td></tr></table></figure></p>
<h3 id="分离构建-目标-和-源文件"><a href="#分离构建-目标-和-源文件" class="headerlink" title="分离构建 目标 和 源文件"></a>分离构建 目标 和 源文件</h3><p>分离构建结果<br><a href="https://scons.org/doc/production/HTML/scons-user/ch15.html">传送门</a><br><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">方式<span class="number">1</span>:</span><br><span class="line">主要是利用这个字段 variant_dir</span><br><span class="line">SConscript(<span class="string">'src/SConscript'</span>, variant_dir=<span class="string">'build'</span>)</span><br><span class="line"></span><br><span class="line">禁掉在输出目录拷贝源文件</span><br><span class="line">SConscript（<span class="string">'src / SConscript'</span>，variant_dir =<span class="string">'build'</span>，duplicate = <span class="number">0</span>）</span><br><span class="line">方式<span class="number">2</span>:</span><br><span class="line">VariantDir(<span class="string">'build'</span>, <span class="string">'src'</span>, duplicate=<span class="number">0</span>)</span><br><span class="line">env = Environment()</span><br><span class="line">env.Program(<span class="string">'build/hello.c'</span>)</span><br><span class="line"></span><br><span class="line">子脚本</span><br><span class="line">VariantDir(<span class="string">'build'</span>, <span class="string">'src'</span>)</span><br><span class="line">SConscript(<span class="string">'build/SConscript'</span>)</span><br></pre></td></tr></table></figure></p>
<h3 id="变体构建"><a href="#变体构建" class="headerlink" title="变体构建"></a>变体构建</h3><p><a href="https://scons.org/doc/production/HTML/scons-user/ch16.html">传送门</a><br>同一个目录构建不同的目标产物(可执行程序)<br><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">platform = ARGUMENTS.get(<span class="string">'OS'</span>, Platform())</span><br><span class="line"></span><br><span class="line">include = <span class="string">"#export/$PLATFORM/include"</span></span><br><span class="line">lib = <span class="string">"#export/$PLATFORM/lib"</span></span><br><span class="line">bin = <span class="string">"#export/$PLATFORM/bin"</span></span><br><span class="line"></span><br><span class="line">env = Environment(PLATFORM = platform,</span><br><span class="line">                  BINDIR = bin,</span><br><span class="line">                  INCDIR = include,</span><br><span class="line">                  LIBDIR = lib,</span><br><span class="line">                  CPPPATH = [include],</span><br><span class="line">                  LIBPATH = [lib],</span><br><span class="line">                  LIBS = <span class="string">'world'</span>)</span><br><span class="line"></span><br><span class="line">Export(<span class="string">'env'</span>)</span><br><span class="line"></span><br><span class="line">env.SConscript(<span class="string">'src/SConscript'</span>, variant_dir=<span class="string">'build/$PLATFORM'</span>)</span><br></pre></td></tr></table></figure></p>
<h3 id="国际化"><a href="#国际化" class="headerlink" title="国际化"></a>国际化</h3><p><a href="https://scons.org/doc/production/HTML/scons-user/ch17.html">传送门</a></p>
<h3 id="编写自己的-builder-构造器"><a href="#编写自己的-builder-构造器" class="headerlink" title="编写自己的 builder(构造器)"></a>编写自己的 builder(构造器)</h3><p><a href="https://scons.org/doc/production/HTML/scons-user/ch18.html">传送门</a><br><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br></pre></td><td class="code"><pre><span class="line">&gt;&gt;&gt;&gt; 创建构造器</span><br><span class="line">env = Environment()</span><br><span class="line">bld = Builder(action = <span class="string">'foobuild &lt; $SOURCE &gt; $TARGET'</span>)</span><br><span class="line">env.Append(BUILDERS = &#123;<span class="string">'Foo'</span> : bld&#125;)</span><br><span class="line">env.Foo(<span class="string">'file.foo'</span>, <span class="string">'file.input'</span>)</span><br><span class="line">env.Program(<span class="string">'hello.c'</span>)</span><br><span class="line"></span><br><span class="line"><span class="keyword">or</span>:</span><br><span class="line">env = Environment()</span><br><span class="line">bld = Builder(action = <span class="string">'foobuild &lt; $SOURCE &gt; $TARGET'</span>)</span><br><span class="line">env[<span class="string">'BUILDERS'</span>][<span class="string">'Foo'</span>] = bld</span><br><span class="line">env.Foo(<span class="string">'file.foo'</span>, <span class="string">'file.input'</span>)</span><br><span class="line">env.Program(<span class="string">'hello.c'</span>)</span><br><span class="line"></span><br><span class="line">&gt;&gt;&gt;&gt; 指定构建的文件后缀 和 输出文件的后缀</span><br><span class="line">bld = Builder(action = <span class="string">'foobuild &lt; $SOURCE &gt; $TARGET'</span>,</span><br><span class="line">              suffix = <span class="string">'.foo'</span>,</span><br><span class="line">              src_suffix = <span class="string">'.input'</span>)</span><br><span class="line">env = Environment(BUILDERS = &#123;<span class="string">'Foo'</span> : bld&#125;)</span><br><span class="line">env.Foo(<span class="string">'file1'</span>)</span><br><span class="line">env.Foo(<span class="string">'file2'</span>)</span><br><span class="line"></span><br><span class="line">&gt;&gt;&gt;&gt; 构建是调用 python 命令 </span><br><span class="line">target:</span><br><span class="line">A list of Node objects representing the target <span class="keyword">or</span> targets to be built by this builder function. The file names of these target(s) may be extracted using the Python str function.</span><br><span class="line">(是一个目标节点列表,可通过 str 的方法 解析里面的内容)</span><br><span class="line">source:</span><br><span class="line">A list of Node objects representing the sources to be used by this builder function to build the targets. The file names of these source(s) may be extracted using the Python str function.</span><br><span class="line">(是一个源节点列表,可通过 str 的方法 解析里面的内容)</span><br><span class="line">env:</span><br><span class="line">The construction environment used <span class="keyword">for</span> building the target(s). The builder function may use any of the environment<span class="string">'s construction variables in any way to affect how it builds the targets.</span></span><br><span class="line"><span class="string">(这个构造变量被用在 目标节点上, 这个构造器可能使用任意的构造环境中的构造变量以任意的方式去影响如何构建目标节点)</span></span><br><span class="line"><span class="string">(这个解释可能有点绕,其实还是挺容易懂得,不是吗?)</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">&gt;&gt;&gt;&gt; 自定义构建函数 上面是三个参数的解释, 很详细.</span></span><br><span class="line"><span class="string">def build_function(target, source, env):</span></span><br><span class="line"><span class="string">    # Code to build "target" from "source"</span></span><br><span class="line"><span class="string">    return None</span></span><br><span class="line"><span class="string">bld = Builder(action = build_function,</span></span><br><span class="line"><span class="string">              suffix = '</span>.foo<span class="string">',</span></span><br><span class="line"><span class="string">              src_suffix = '</span>.input<span class="string">')</span></span><br><span class="line"><span class="string">env = Environment(BUILDERS = &#123;'</span>Foo<span class="string">' : bld&#125;)</span></span><br><span class="line"><span class="string">env.Foo('</span>file<span class="string">')</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">&gt;&gt;&gt;&gt; Generator 产生一条记录信息</span></span><br><span class="line"><span class="string">def generate_actions(source, target, env, for_signature):</span></span><br><span class="line"><span class="string">    return '</span>foobuild &lt; %s &gt; %s<span class="string">' % (source[0], target[0])</span></span><br><span class="line"><span class="string">bld = Builder(generator = generate_actions,</span></span><br><span class="line"><span class="string">              suffix = '</span>.foo<span class="string">',</span></span><br><span class="line"><span class="string">              src_suffix = '</span>.input<span class="string">')</span></span><br><span class="line"><span class="string">env = Environment(BUILDERS = &#123;'</span>Foo<span class="string">' : bld&#125;)</span></span><br><span class="line"><span class="string">env.Foo('</span>file<span class="string">')</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">&gt;&gt;&gt;&gt; Builders That Modify the Target or Source Lists Using an Emitter</span></span><br><span class="line"><span class="string">(修改目标节点或者是 源节点 通过发射器)</span></span><br><span class="line"><span class="string">bld = Builder(action = '</span>my_command $SOURCES &gt; $TARGET<span class="string">',</span></span><br><span class="line"><span class="string">              suffix = '</span>.foo<span class="string">',</span></span><br><span class="line"><span class="string">              src_suffix = '</span>.input<span class="string">',</span></span><br><span class="line"><span class="string">              emitter = '</span>$MY_EMITTER<span class="string">')</span></span><br><span class="line"><span class="string">def modify1(target, source, env):</span></span><br><span class="line"><span class="string">    return target, source + ['</span>modify1.<span class="keyword">in</span><span class="string">']</span></span><br><span class="line"><span class="string">def modify2(target, source, env):</span></span><br><span class="line"><span class="string">    return target, source + ['</span>modify2.<span class="keyword">in</span><span class="string">']</span></span><br><span class="line"><span class="string">env1 = Environment(BUILDERS = &#123;'</span>Foo<span class="string">' : bld&#125;,</span></span><br><span class="line"><span class="string">                   MY_EMITTER = modify1)</span></span><br><span class="line"><span class="string">env2 = Environment(BUILDERS = &#123;'</span>Foo<span class="string">' : bld&#125;,</span></span><br><span class="line"><span class="string">                   MY_EMITTER = modify2)</span></span><br><span class="line"><span class="string">env1.Foo('</span>file1<span class="string">')</span></span><br><span class="line"><span class="string">env2.Foo('</span>file2<span class="string">')</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">&gt;&gt;&gt;&gt; 放置自定义工具或者是 构造器</span></span><br><span class="line"><span class="string">&gt;&gt;&gt;&gt; scons 会自动加载 site_scons/site_init.py 比任意一个 构建脚本都早</span></span><br><span class="line"><span class="string">&gt;&gt;&gt;&gt; site_scons/site_tools 在顶级的构建脚本是最后执行的 它覆盖其他的构建脚本定义</span></span><br><span class="line"><span class="string">&gt;&gt;&gt;&gt; </span></span><br><span class="line"><span class="string">site_scons/site_init.py</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">def TOOL_ADD_HEADER(env):</span></span><br><span class="line"><span class="string">   """A Tool to add a header from $HEADER to the source file"""</span></span><br><span class="line"><span class="string">   add_header = Builder(action=['</span>echo <span class="string">"$HEADER"</span> &gt; $TARGET<span class="string">',</span></span><br><span class="line"><span class="string">                                '</span>cat $SOURCE &gt;&gt; $TARGET<span class="string">'])</span></span><br><span class="line"><span class="string">   env.Append(BUILDERS = &#123;'</span>AddHeade<span class="string">r' : add_header&#125;)</span></span><br><span class="line"><span class="string">   env['</span>HEADER<span class="string">'] = '</span><span class="string">' # set default value</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">SConstruct</span></span><br><span class="line"><span class="string"># Use TOOL_ADD_HEADER from site_scons/site_init.py</span></span><br><span class="line"><span class="string">env=Environment(tools=['</span>default<span class="string">', TOOL_ADD_HEADER], HEADER="=====")</span></span><br><span class="line"><span class="string">env.AddHeader('</span>tgt<span class="string">', '</span>src<span class="string">')</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">site_scons/my_utils.py</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">from SCons.Script import *   # for Execute and Mkdir</span></span><br><span class="line"><span class="string">def build_id():</span></span><br><span class="line"><span class="string">   """Return a build ID (stub version)"""</span></span><br><span class="line"><span class="string">   return "100"</span></span><br><span class="line"><span class="string">def MakeWorkDir(workdir):</span></span><br><span class="line"><span class="string">   """Create the specified dir immediately"""</span></span><br><span class="line"><span class="string">   Execute(Mkdir(workdir))</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">import my_utils</span></span><br><span class="line"><span class="string">print("build_id=" + my_utils.build_id())</span></span><br><span class="line"><span class="string">my_utils.MakeWorkDir('</span>/tmp/work<span class="string">')</span></span><br></pre></td></tr></table></figure></p>
<h3 id="缓存构建的文件"><a href="#缓存构建的文件" class="headerlink" title="缓存构建的文件"></a>缓存构建的文件</h3><p>缓存构建文件其实就是将构建出来的中间产物给放到一个缓存目录里面,如果目录文件不存,就直接构建中间产物,在其下次构建是,就不必再次构建它,提高构建效率.<br><a href="https://scons.org/doc/production/HTML/scons-user/ch24.html">传送门</a></p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line">&gt;&gt;&gt;&gt; 主要使用 CacheDir(<span class="string">'./cache'</span>)</span><br><span class="line">&gt;&gt;&gt;&gt; scons -Q  --cache-show  保持每次构建的显示命令都是一样, 不使用这个字段会出现如果在在缓存里面存在,就和没有时的输出不一样,问题.</span><br><span class="line">ej:</span><br><span class="line">    % scons -Q</span><br><span class="line">    cc -o hello.o -c hello.c</span><br><span class="line">    cc -o hello hello.o</span><br><span class="line">    % scons -Q -c</span><br><span class="line">    Removed hello.o</span><br><span class="line">    Removed hello</span><br><span class="line">    % scons -Q --cache-show</span><br><span class="line">    cc -o hello.o -c hello.c</span><br><span class="line">    cc -o hello hello.o</span><br><span class="line"></span><br><span class="line">&gt;&gt;&gt;&gt; NoCache() 指定某些中间产物,不放入缓存</span><br><span class="line">ej:</span><br><span class="line">    env = Environment()</span><br><span class="line">    obj = env.Object(<span class="string">'hello.c'</span>)</span><br><span class="line">    env.Program(<span class="string">'hello.c'</span>)</span><br><span class="line">    CacheDir(<span class="string">'cache'</span>)</span><br><span class="line">    NoCache(<span class="string">'hello.o'</span>)</span><br><span class="line"></span><br><span class="line">&gt;&gt;&gt;&gt; scons -Q --cache-disable 通过命令行禁掉 缓存</span><br><span class="line">&gt;&gt;&gt;&gt; scons -Q --cache-force 强制更新缓存</span><br><span class="line">&gt;&gt;&gt;&gt; scons -Q --random 随机缓存 或者是使用构建脚本设置 SetOption(<span class="string">'random'</span>, <span class="number">1</span>)</span><br><span class="line">-- random 主要是面对多个程序通同时构建的情况. 让他的构建库的顺序尽量不一致,最小化减少缓存.</span><br></pre></td></tr></table></figure>
<h3 id="验证-python-scons-版本"><a href="#验证-python-scons-版本" class="headerlink" title="验证 python scons 版本"></a>验证 python scons 版本</h3><p>EnsurePythonVersion(2, 5) 验证 python 版本 如果低于构建结束<br>EnsureSConsVersion(1, 0) 验证 scons 版本</p>
<h3 id="别名目标"><a href="#别名目标" class="headerlink" title="别名目标"></a>别名目标</h3><p>别名也没啥说的<br><a href="https://scons.org/doc/production/HTML/scons-user/ch25.html">传送门</a><br><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">env = Environment()</span><br><span class="line">hello = env.Program(<span class="string">'hello.c'</span>)</span><br><span class="line">env.Install(<span class="string">'/usr/bin'</span>, hello)</span><br><span class="line">env.Alias(<span class="string">'install'</span>, <span class="string">'/usr/bin'</span>)</span><br></pre></td></tr></table></figure></p>
<h3 id="多平台配置（Autoconf功能"><a href="#多平台配置（Autoconf功能" class="headerlink" title="多平台配置（Autoconf功能"></a>多平台配置（Autoconf功能</h3><p>主要是检查某些依赖的文件是否存在等等.<br><a href="https://scons.org/doc/production/HTML/scons-user/ch23.html">传送门</a></p>
<h3 id="从代码存储库构建"><a href="#从代码存储库构建" class="headerlink" title="从代码存储库构建"></a>从代码存储库构建</h3><p><a href="https://scons.org/doc/production/HTML/scons-user/ch22.html">传送门</a></p>
<h3 id="编写扫描仪"><a href="#编写扫描仪" class="headerlink" title="编写扫描仪"></a>编写扫描仪</h3><p><a href="https://scons.org/doc/production/HTML/scons-user/ch21.html">传送门</a></p>
<h3 id="Not-Writing-a-Builder-the-Command-Builder"><a href="#Not-Writing-a-Builder-the-Command-Builder" class="headerlink" title="Not Writing a Builder: the Command Builder"></a>Not Writing a Builder: the Command Builder</h3><p>主要是自定义写构造器的简化版本<br><a href="https://scons.org/doc/production/HTML/scons-user/ch19.html">传送门</a></p>
<h3 id="Pseudo-Builders-the-AddMethod-function-伪造构建起-添加方法"><a href="#Pseudo-Builders-the-AddMethod-function-伪造构建起-添加方法" class="headerlink" title="Pseudo-Builders: the AddMethod function(伪造构建起, 添加方法)"></a>Pseudo-Builders: the AddMethod function(伪造构建起, 添加方法)</h3><p>这个东西个自定义工具差不多<br><a href="https://scons.org/doc/production/HTML/scons-user/ch20.html">传送门</a></p>

            <div class="post-copyright">
    <div class="content">
        <p>最后更新： 2019年08月14日 11:22</p>
        <p>原始链接： <a class="post-url" href="/posts/66615451/" title="scons自动构建工具(二)">https://leng521.top/posts/66615451/</a></p>
        <footer>
            <a href="https://leng521.top">
                <img src="/head.jpg" alt="小魏">
                小魏
            </a>
        </footer>
    </div>
</div>

      
        
            

        
    </div>
    <footer class="article-footer">
        
        
<div class="post-share">
    <a href="javascript:;" id="share-sub" class="post-share-fab">
        <i class="fa fa-share-alt"></i>
    </a>
    <div class="post-share-list" id="share-list">
        <ul class="share-icons">
          <li>
            <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=https://leng521.top/posts/66615451/&title=《scons自动构建工具(二)》 — 小魏的博客&pic=https://leng521.tophead.jpg" data-title="微博">
              <i class="fa fa-weibo"></i>
            </a>
          </li>
          <li>
            <a class="weixin share-sns" id="wxFab" href="javascript:;" data-title="微信">
              <i class="fa fa-weixin"></i>
            </a>
          </li>
          <li>
            <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=https://leng521.top/posts/66615451/&title=《scons自动构建工具(二)》 — 小魏的博客&source=上一篇好像写的有点长了,上传不上去,所以又写了第二篇续写第一篇.
环境变量影响 scons 构建it uses the dictionary stored..." data-title="QQ">
              <i class="fa fa-qq"></i>
            </a>
          </li>
          <li>
            <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=https://leng521.top/posts/66615451/" data-title="Facebook">
              <i class="fa fa-facebook"></i>
            </a>
          </li>
          <li>
            <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《scons自动构建工具(二)》 — 小魏的博客&url=https://leng521.top/posts/66615451/&via=https://leng521.top" data-title="Twitter">
              <i class="fa fa-twitter"></i>
            </a>
          </li>
          <li>
            <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=https://leng521.top/posts/66615451/" data-title="Google+">
              <i class="fa fa-google-plus"></i>
            </a>
          </li>
        </ul>
     </div>
</div>
<div class="post-modal wx-share" id="wxShare">
    <a class="close" href="javascript:;" id="wxShare-close">×</a>
    <p>扫一扫，分享到微信</p>
    <img src="" alt="微信分享二维码">
</div>

<div class="mask"></div>

        
        <ul class="article-footer-menu">
            
            
  <li class="article-footer-tags">
    <i class="fa fa-tags"></i>
      
    <a href="/tags/python/" class="color2">python</a>
      
    <a href="/tags/c++/" class="color4">c++</a>
      
    <a href="/tags/scons/" class="color1">scons</a>
      
  </li>

        </ul>
        
    </footer>
  </div>
</article>


    <aside class="post-toc-pos post-toc-top" id="post-toc">
        <nav class="post-toc-wrap">
            <ol class="post-toc"><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#环境变量影响-scons-构建"><span class="post-toc-text">环境变量影响 scons 构建</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#使用外部工具"><span class="post-toc-text">使用外部工具</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#在构建程序的时候-帮助信息"><span class="post-toc-text">在构建程序的时候 帮助信息</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#从命令行控制构建流程"><span class="post-toc-text">从命令行控制构建流程</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#InstallBuilder-安装构建的可执行程序"><span class="post-toc-text">InstallBuilder 安装构建的可执行程序</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#与平台无关的文件操作"><span class="post-toc-text">与平台无关的文件操作</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#控制构建目标的移除"><span class="post-toc-text">控制构建目标的移除</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#分级构建"><span class="post-toc-text">分级构建</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#分离构建-目标-和-源文件"><span class="post-toc-text">分离构建 目标 和 源文件</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#变体构建"><span class="post-toc-text">变体构建</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#国际化"><span class="post-toc-text">国际化</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#编写自己的-builder-构造器"><span class="post-toc-text">编写自己的 builder(构造器)</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#缓存构建的文件"><span class="post-toc-text">缓存构建的文件</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#验证-python-scons-版本"><span class="post-toc-text">验证 python scons 版本</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#别名目标"><span class="post-toc-text">别名目标</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#多平台配置（Autoconf功能"><span class="post-toc-text">多平台配置（Autoconf功能</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#从代码存储库构建"><span class="post-toc-text">从代码存储库构建</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#编写扫描仪"><span class="post-toc-text">编写扫描仪</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#Not-Writing-a-Builder-the-Command-Builder"><span class="post-toc-text">Not Writing a Builder: the Command Builder</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#Pseudo-Builders-the-AddMethod-function-伪造构建起-添加方法"><span class="post-toc-text">Pseudo-Builders: the AddMethod function(伪造构建起, 添加方法)</span></a></li></ol>
        </nav>
    </aside>
    

<nav id="article-nav">
  
    <a href="/posts/b0c8e6a5/" id="article-nav-newer" class="article-nav-link-wrap">

      <span class="article-nav-title">
        <i class="fa fa-hand-o-left" aria-hidden="true"></i>
        
          git操作命令记录(二)
        
      </span>
    </a>
  
  
    <a href="/posts/79065537/" id="article-nav-older" class="article-nav-link-wrap">
      <span class="article-nav-title">scons自动构建工具</span>
      <i class="fa fa-hand-o-right" aria-hidden="true"></i>
    </a>
  
</nav>



    
        <!-- 来必力City版安装代码 -->
<div id="lv-container" data-id="city" data-uid="MTAyMC8zNDA0MC8xMDU3OA==">
<script type="text/javascript">
   (function(d, s) {
       var j, e = d.getElementsByTagName(s)[0];

       if (typeof LivereTower === 'function') { return; }

       j = d.createElement(s);
       j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
       j.async = true;

       e.parentNode.insertBefore(j, e);
   })(document, 'script');
</script>
<noscript>为正常使用来必力评论功能请激活JavaScript</noscript>
</div>
<!-- City版安装代码已完成 -->
    
</section>
        
      </div>
      <footer id="footer">
  <div class="outer">
    <div id="footer-info" class="inner">
      
<p>
    <span id="busuanzi_container_site_uv" style='display:none'>
        总访客数：<span id="busuanzi_value_site_uv"></span>
    </span>
    <span id="busuanzi_container_site_pv" style='display:none'>
        总访问量：<span id="busuanzi_value_site_pv"></span>
    </span>
</p>


      <p>
        Powered by  <a href="http://hexo.io/" target="_blank">Hexo</a>
        Theme <a href="//github.com/wongminho/hexo-theme-miho" target="_blank">MiHo</a>
      &copy; 2019 小魏<br>
      </p>
    </div>
  </div>
</footer>
    <script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<script src="//cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script>
  var mihoConfig = {
      root: "https://leng521.top",
      animate: true,
      isHome: false,
      share: true,
      reward: 0
  }
</script>
<div class="sidebar">
    <div id="sidebar-search" title="Search">
        <i class="fa fa-search"></i>
    </div>
    <div id="sidebar-category" title="Categories">
        <i class="fa fa-book"></i>
    </div>
    <div id="sidebar-tag" title="Tags">
        <i class="fa fa-tags"></i>
    </div>
    <div id="sidebar-top">
        <span class="sidebar-top-icon"><i class="fa fa-angle-up"></i></span>
    </div>
</div>
<div class="sidebar-menu-box" id="sidebar-menu-box">
    <div class="sidebar-menu-box-container">
        <div id="sidebar-menu-box-categories">
            <a class="category-link" href="/categories/Cocos-Creator/">Cocos Creator</a><a class="category-link" href="/categories/QQ玩一玩/">QQ玩一玩</a><a class="category-link" href="/categories/cocos2d-x/">cocos2d-x</a><a class="category-link" href="/categories/cocos2dx/">cocos2dx</a><a class="category-link" href="/categories/git/">git</a><a class="category-link" href="/categories/hexo/">hexo</a><a class="category-link" href="/categories/js/">js</a><a class="category-link" href="/categories/linux/">linux</a><a class="category-link" href="/categories/python/">python</a><a class="category-link" href="/categories/前端/">前端</a><a class="category-link" href="/categories/前端/WebGL/">WebGL</a><a class="category-link" href="/categories/前端/bgfx/">bgfx</a><a class="category-link" href="/categories/后端/">后端</a><a class="category-link" href="/categories/后端/golang/">golang</a><a class="category-link" href="/categories/后端/golang/protobuf/">protobuf</a><a class="category-link" href="/categories/后端/nodejs/">nodejs</a><a class="category-link" href="/categories/微信小游戏/">微信小游戏</a><a class="category-link" href="/categories/插件/">插件</a><a class="category-link" href="/categories/自动构建工具/">自动构建工具</a>
        </div>
        <div id="sidebar-menu-box-tags">
            <a href="/tags/9宫格/" style="font-size: 10px;">9宫格</a> <a href="/tags/Cocos-Creator/" style="font-size: 20px;">Cocos Creator</a> <a href="/tags/IT/" style="font-size: 10px;">IT</a> <a href="/tags/QQ玩一玩/" style="font-size: 10px;">QQ玩一玩</a> <a href="/tags/TweenLite/" style="font-size: 10px;">TweenLite</a> <a href="/tags/WebGL/" style="font-size: 10px;">WebGL</a> <a href="/tags/android-studio/" style="font-size: 10px;">android studio</a> <a href="/tags/bgfx/" style="font-size: 12.5px;">bgfx</a> <a href="/tags/c/" style="font-size: 12.5px;">c++</a> <a href="/tags/cocos2d-x/" style="font-size: 15px;">cocos2d-x</a> <a href="/tags/cpp/" style="font-size: 12.5px;">cpp</a> <a href="/tags/gcc/" style="font-size: 10px;">gcc</a> <a href="/tags/git/" style="font-size: 10px;">git</a> <a href="/tags/git-扩展工具/" style="font-size: 10px;">git 扩展工具</a> <a href="/tags/github-page/" style="font-size: 10px;">github page</a> <a href="/tags/git命令/" style="font-size: 10px;">git命令</a> <a href="/tags/golang/" style="font-size: 15px;">golang</a> <a href="/tags/hello-world/" style="font-size: 10px;">hello world</a> <a href="/tags/hexo/" style="font-size: 12.5px;">hexo</a> <a href="/tags/js/" style="font-size: 12.5px;">js</a> <a href="/tags/lua/" style="font-size: 12.5px;">lua</a> <a href="/tags/nodejs/" style="font-size: 10px;">nodejs</a> <a href="/tags/optionParser/" style="font-size: 10px;">optionParser</a> <a href="/tags/protobuf/" style="font-size: 10px;">protobuf</a> <a href="/tags/python/" style="font-size: 17.5px;">python</a> <a href="/tags/scons/" style="font-size: 12.5px;">scons</a> <a href="/tags/spine/" style="font-size: 10px;">spine</a> <a href="/tags/sublime插件/" style="font-size: 10px;">sublime插件</a> <a href="/tags/websocket/" style="font-size: 10px;">websocket</a> <a href="/tags/xmake/" style="font-size: 12.5px;">xmake</a> <a href="/tags/优化/" style="font-size: 12.5px;">优化</a> <a href="/tags/前端/" style="font-size: 15px;">前端</a> <a href="/tags/博客/" style="font-size: 10px;">博客</a> <a href="/tags/原型链/" style="font-size: 10px;">原型链</a> <a href="/tags/后端/" style="font-size: 10px;">后端</a> <a href="/tags/广告/" style="font-size: 10px;">广告</a> <a href="/tags/微信小游戏/" style="font-size: 20px;">微信小游戏</a> <a href="/tags/缺少dll/" style="font-size: 10px;">缺少dll</a> <a href="/tags/闭包/" style="font-size: 10px;">闭包</a>
        </div>
    </div>
    <a href="javascript:;" class="sidebar-menu-box-close">&times;</a>
</div>
<div class="mobile-header-menu-nav" id="mobile-header-menu-nav">
    <div class="mobile-header-menu-container">
        <span class="title">Menus</span>
        <ul class="mobile-header-menu-navbar">
            
            <li>
                <a  href="/">
                    <i class="fa fa-home"></i><span>Home</span>
                </a>
            </li>
            
            <li>
                <a  href="/archives">
                    <i class="fa fa-archive"></i><span>Archives</span>
                </a>
            </li>
            
            <li>
                <a  href="/about">
                    <i class="fa fa-user"></i><span>About</span>
                </a>
            </li>
            
        </ul>
    </div>
    <div class="mobile-header-tag-container">
        <span class="title">Tags</span>
        <div id="mobile-header-container-tags">
            <a href="/tags/9宫格/" style="font-size: 10px;">9宫格</a> <a href="/tags/Cocos-Creator/" style="font-size: 20px;">Cocos Creator</a> <a href="/tags/IT/" style="font-size: 10px;">IT</a> <a href="/tags/QQ玩一玩/" style="font-size: 10px;">QQ玩一玩</a> <a href="/tags/TweenLite/" style="font-size: 10px;">TweenLite</a> <a href="/tags/WebGL/" style="font-size: 10px;">WebGL</a> <a href="/tags/android-studio/" style="font-size: 10px;">android studio</a> <a href="/tags/bgfx/" style="font-size: 12.5px;">bgfx</a> <a href="/tags/c/" style="font-size: 12.5px;">c++</a> <a href="/tags/cocos2d-x/" style="font-size: 15px;">cocos2d-x</a> <a href="/tags/cpp/" style="font-size: 12.5px;">cpp</a> <a href="/tags/gcc/" style="font-size: 10px;">gcc</a> <a href="/tags/git/" style="font-size: 10px;">git</a> <a href="/tags/git-扩展工具/" style="font-size: 10px;">git 扩展工具</a> <a href="/tags/github-page/" style="font-size: 10px;">github page</a> <a href="/tags/git命令/" style="font-size: 10px;">git命令</a> <a href="/tags/golang/" style="font-size: 15px;">golang</a> <a href="/tags/hello-world/" style="font-size: 10px;">hello world</a> <a href="/tags/hexo/" style="font-size: 12.5px;">hexo</a> <a href="/tags/js/" style="font-size: 12.5px;">js</a> <a href="/tags/lua/" style="font-size: 12.5px;">lua</a> <a href="/tags/nodejs/" style="font-size: 10px;">nodejs</a> <a href="/tags/optionParser/" style="font-size: 10px;">optionParser</a> <a href="/tags/protobuf/" style="font-size: 10px;">protobuf</a> <a href="/tags/python/" style="font-size: 17.5px;">python</a> <a href="/tags/scons/" style="font-size: 12.5px;">scons</a> <a href="/tags/spine/" style="font-size: 10px;">spine</a> <a href="/tags/sublime插件/" style="font-size: 10px;">sublime插件</a> <a href="/tags/websocket/" style="font-size: 10px;">websocket</a> <a href="/tags/xmake/" style="font-size: 12.5px;">xmake</a> <a href="/tags/优化/" style="font-size: 12.5px;">优化</a> <a href="/tags/前端/" style="font-size: 15px;">前端</a> <a href="/tags/博客/" style="font-size: 10px;">博客</a> <a href="/tags/原型链/" style="font-size: 10px;">原型链</a> <a href="/tags/后端/" style="font-size: 10px;">后端</a> <a href="/tags/广告/" style="font-size: 10px;">广告</a> <a href="/tags/微信小游戏/" style="font-size: 20px;">微信小游戏</a> <a href="/tags/缺少dll/" style="font-size: 10px;">缺少dll</a> <a href="/tags/闭包/" style="font-size: 10px;">闭包</a>
        </div>
    </div>
</div>
<div class="search-wrap">
    <span class="search-close">&times;</span>
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="back">
            <i class="icon icon-lg icon-chevron-left"></i>
        </a>
        <input class="search-field" placeholder="Search..." id="keywords">
        <a id="search-submit" href="javascript:;">
            <i class="fa fa-search"></i>
        </a>
    <div class="search-container" id="search-container">
        <ul class="search-result" id="search-result">
        </ul>
    </div>
</div>

<div id="search-tpl">
    <li class="search-result-item">
        <a href="{url}" class="search-item-li">
            <span class="search-item-li-title" title="{title}">{title}</span>
        </a>
    </li>
</div>
<script src="/js/search.js"></script>
<script src="/js/main.js"></script>


  <script src="//cdn.bootcss.com/particles.js/2.0.0/particles.min.js"></script>
  <div id="particles"></div>
  <script src="/js/particles.js"></script>







  <link rel="stylesheet" href="//cdn.bootcss.com/animate.css/3.5.0/animate.min.css">
  <script src="//cdn.bootcss.com/scrollReveal.js/3.0.5/scrollreveal.js"></script>
  <script src="/js/animate.js"></script>


  <script src="/js/pop-img.js"></script>
  <script>
     $(".article-entry p img").popImg();
  </script>

  </div>
</body>
</html>